home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DatabaseAccess.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  12.4 KB  |  352 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DatabaseAccess.p
  3.  
  4.      Contains:    Database Access Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT DatabaseAccess;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __DATABASEACCESS__}
  27. {$SETC __DATABASEACCESS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC DatabaseAccessIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __RESOURCES__}
  34. {$I Resources.p}
  35. {$ENDC}
  36.  
  37.  
  38. {$PUSH}
  39. {$ALIGN MAC68K}
  40. {$LibExport+}
  41.  
  42. { data type codes }
  43.  
  44. CONST
  45.     typeNone                    = 'none';
  46.     typeDate                    = 'date';
  47.     typeTime                    = 'time';
  48.     typeTimeStamp                = 'tims';
  49.     typeDecimal                    = 'deci';
  50.     typeMoney                    = 'mone';
  51.     typeVChar                    = 'vcha';
  52.     typeVBin                    = 'vbin';
  53.     typeLChar                    = 'lcha';
  54.     typeLBin                    = 'lbin';
  55.     typeDiscard                    = 'disc';                        {  "dummy" types for DBResultsToText  }
  56.     typeUnknown                    = 'unkn';
  57.     typeColBreak                = 'colb';
  58.     typeRowBreak                = 'rowb';                        {  pass this in to DBGetItem for any data type  }
  59.     typeAnyType                    = 0;
  60.  
  61. { infinite timeout value for DBGetItem }
  62.                                                                 {  messages for status functions for DBStartQuery  }
  63.     kDBUpdateWind                = 0;
  64.     kDBAboutToInit                = 1;
  65.     kDBInitComplete                = 2;
  66.     kDBSendComplete                = 3;
  67.     kDBExecComplete                = 4;
  68.     kDBStartQueryComplete        = 5;
  69.  
  70.                                                                 {  messages for status functions for DBGetQueryResults  }
  71.     kDBGetItemComplete            = 6;
  72.     kDBGetQueryResultsComplete    = 7;
  73.     kDBWaitForever                = -1;
  74.  
  75.                                                                 {   flags for DBGetItem   }
  76.     kDBLastColFlag                = $0001;
  77.     kDBNullFlag                    = $0004;
  78.  
  79.  
  80. TYPE
  81.     DBType                                = OSType;
  82.     DBAsyncParamBlockRecPtr = ^DBAsyncParamBlockRec;
  83.     DBAsyncParmBlkPtr                    = ^DBAsyncParamBlockRec;
  84. {$IFC TYPED_FUNCTION_POINTERS}
  85.     DBCompletionProcPtr = PROCEDURE(pb: DBAsyncParmBlkPtr);
  86. {$ELSEC}
  87.     DBCompletionProcPtr = Register68kProcPtr;
  88. {$ENDC}
  89.  
  90.     DBCompletionUPP = UniversalProcPtr;
  91. { structure for asynchronous parameter block }
  92.     DBAsyncParamBlockRec = RECORD
  93.         completionProc:            DBCompletionUPP;                        {  pointer to completion routine  }
  94.         result:                    OSErr;                                    {  result of call  }
  95.         userRef:                LONGINT;                                {  for application's use  }
  96.         ddevRef:                LONGINT;                                {  for ddev's use  }
  97.         reserved:                LONGINT;                                {  for internal use  }
  98.     END;
  99.  
  100. { structure for resource list in QueryRecord }
  101.     ResListElemPtr = ^ResListElem;
  102.     ResListElem = RECORD
  103.         theType:                ResType;                                {  resource type  }
  104.         id:                        INTEGER;                                {  resource id  }
  105.     END;
  106.  
  107.     ResListPtr                            = ^ResListElem;
  108.     ResListHandle                        = ^ResListPtr;
  109. { structure for query list in QueryRecord }
  110.     QueryArray                            = ARRAY [0..255] OF Handle;
  111.     QueryListPtr                        = ^QueryArray;
  112.     QueryListHandle                        = ^QueryListPtr;
  113.     QueryRecordPtr = ^QueryRecord;
  114.     QueryRecord = RECORD
  115.         version:                INTEGER;                                {  version  }
  116.         id:                        INTEGER;                                {  id of 'qrsc' this came from  }
  117.         queryProc:                Handle;                                    {  handle to query def proc  }
  118.         ddevName:                Str63;                                    {  ddev name  }
  119.         host:                    Str255;                                    {  host name  }
  120.         user:                    Str255;                                    {  user name  }
  121.         password:                Str255;                                    {  password  }
  122.         connStr:                Str255;                                    {  connection string  }
  123.         currQuery:                INTEGER;                                {  index of current query  }
  124.         numQueries:                INTEGER;                                {  number of queries in list  }
  125.         queryList:                QueryListHandle;                        {  handle to array of handles to text  }
  126.         numRes:                    INTEGER;                                {  number of resources in list  }
  127.         resList:                ResListHandle;                            {  handle to array of resource list elements  }
  128.         dataHandle:                Handle;                                    {  for use by query def proc  }
  129.         refCon:                    LONGINT;                                {  for use by application  }
  130.     END;
  131.  
  132.     QueryPtr                            = ^QueryRecord;
  133.     QueryHandle                            = ^QueryPtr;
  134. { structure of column types array in ResultsRecord }
  135.     ColTypesArray                        = ARRAY [0..255] OF DBType;
  136.     ColTypesPtr                            = ^ColTypesArray;
  137.     ColTypesHandle                        = ^ColTypesPtr;
  138. { structure for column info in ResultsRecord }
  139.     DBColInfoRecordPtr = ^DBColInfoRecord;
  140.     DBColInfoRecord = RECORD
  141.         len:                    INTEGER;
  142.         places:                    INTEGER;
  143.         flags:                    INTEGER;
  144.     END;
  145.  
  146.     ColInfoArray                        = ARRAY [0..255] OF DBColInfoRecord;
  147.     ColInfoPtr                            = ^ColInfoArray;
  148.     ColInfoHandle                        = ^ColInfoPtr;
  149. { structure of results returned by DBGetResults }
  150.     ResultsRecordPtr = ^ResultsRecord;
  151.     ResultsRecord = RECORD
  152.         numRows:                INTEGER;                                {  number of rows in result  }
  153.         numCols:                INTEGER;                                {  number of columns per row  }
  154.         colTypes:                ColTypesHandle;                            {  data type array  }
  155.         colData:                Handle;                                    {  actual results  }
  156.         colInfo:                ColInfoHandle;                            {  DBColInfoRecord array  }
  157.     END;
  158.  
  159.  
  160. CONST
  161.                                                                 {  messages sent to a 'ddev' }
  162.     kDBInit                        = 0;
  163.     kDBEnd                        = 1;
  164.     kDBGetConnInfo                = 2;
  165.     kDBGetSessionNum            = 3;
  166.     kDBSend                        = 4;
  167.     kDBSendItem                    = 5;
  168.     kDBExec                        = 6;
  169.     kDBState                    = 7;
  170.     kDBGetErr                    = 8;
  171.     kDBBreak                    = 9;
  172.     kDBGetItem                    = 10;
  173.     kDBUngetItem                = 11;
  174.     kDBKill                        = 12;
  175.     kDBOpen                        = 100;
  176.     kDBClose                    = 101;
  177.     kDBIdle                        = 102;
  178.  
  179.  
  180. TYPE
  181. {$IFC TYPED_FUNCTION_POINTERS}
  182.     DBQueryDefProcPtr = FUNCTION(VAR sessID: LONGINT; query: QueryHandle): OSErr;
  183. {$ELSEC}
  184.     DBQueryDefProcPtr = ProcPtr;
  185. {$ENDC}
  186.  
  187. {$IFC TYPED_FUNCTION_POINTERS}
  188.     DBStatusProcPtr = FUNCTION(message: INTEGER; result: OSErr; dataLen: INTEGER; dataPlaces: INTEGER; dataFlags: INTEGER; dataType: DBType; dataPtr: Ptr): BOOLEAN;
  189. {$ELSEC}
  190.     DBStatusProcPtr = ProcPtr;
  191. {$ENDC}
  192.  
  193. {$IFC TYPED_FUNCTION_POINTERS}
  194.     DBResultHandlerProcPtr = FUNCTION(dataType: DBType; theLen: INTEGER; thePlaces: INTEGER; theFlags: INTEGER; theData: Ptr; theText: Handle): OSErr;
  195. {$ELSEC}
  196.     DBResultHandlerProcPtr = ProcPtr;
  197. {$ENDC}
  198.  
  199.     DBQueryDefUPP = UniversalProcPtr;
  200.     DBStatusUPP = UniversalProcPtr;
  201.     DBResultHandlerUPP = UniversalProcPtr;
  202.  
  203. CONST
  204.     uppDBCompletionProcInfo = $0000B802;
  205.     uppDBQueryDefProcInfo = $000003E0;
  206.     uppDBStatusProcInfo = $000FAA90;
  207.     uppDBResultHandlerProcInfo = $0003EAE0;
  208.  
  209. FUNCTION NewDBCompletionProc(userRoutine: DBCompletionProcPtr): DBCompletionUPP;
  210.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  211.     INLINE $2E9F;
  212.     {$ENDC}
  213.  
  214. FUNCTION NewDBQueryDefProc(userRoutine: DBQueryDefProcPtr): DBQueryDefUPP;
  215.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  216.     INLINE $2E9F;
  217.     {$ENDC}
  218.  
  219. FUNCTION NewDBStatusProc(userRoutine: DBStatusProcPtr): DBStatusUPP;
  220.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  221.     INLINE $2E9F;
  222.     {$ENDC}
  223.  
  224. FUNCTION NewDBResultHandlerProc(userRoutine: DBResultHandlerProcPtr): DBResultHandlerUPP;
  225.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  226.     INLINE $2E9F;
  227.     {$ENDC}
  228.  
  229. PROCEDURE CallDBCompletionProc(pb: DBAsyncParmBlkPtr; userRoutine: DBCompletionUPP);
  230.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  231.     {To be implemented:  Glue to move parameters into registers.}
  232.     {$ENDC}
  233.  
  234. FUNCTION CallDBQueryDefProc(VAR sessID: LONGINT; query: QueryHandle; userRoutine: DBQueryDefUPP): OSErr;
  235.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  236.     INLINE $205F, $4E90;
  237.     {$ENDC}
  238.  
  239. FUNCTION CallDBStatusProc(message: INTEGER; result: OSErr; dataLen: INTEGER; dataPlaces: INTEGER; dataFlags: INTEGER; dataType: DBType; dataPtr: Ptr; userRoutine: DBStatusUPP): BOOLEAN;
  240.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  241.     INLINE $205F, $4E90;
  242.     {$ENDC}
  243.  
  244. FUNCTION CallDBResultHandlerProc(dataType: DBType; theLen: INTEGER; thePlaces: INTEGER; theFlags: INTEGER; theData: Ptr; theText: Handle; userRoutine: DBResultHandlerUPP): OSErr;
  245.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  246.     INLINE $205F, $4E90;
  247.     {$ENDC}
  248. FUNCTION InitDBPack: OSErr;
  249.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  250.     INLINE $3F3C, $0004, $303C, $0100, $A82F;
  251.     {$ENDC}
  252. FUNCTION DBInit(VAR sessID: LONGINT; ddevName: Str63; host: Str255; user: Str255; passwd: Str255; connStr: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  253.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  254.     INLINE $303C, $0E02, $A82F;
  255.     {$ENDC}
  256. FUNCTION DBEnd(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  257.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  258.     INLINE $303C, $0403, $A82F;
  259.     {$ENDC}
  260. FUNCTION DBGetConnInfo(sessID: LONGINT; sessNum: INTEGER; VAR returnedID: LONGINT; VAR version: LONGINT; VAR ddevName: Str63; VAR host: Str255; VAR user: Str255; VAR network: Str255; VAR connStr: Str255; VAR start: LONGINT; VAR state: OSErr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  261.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  262.     INLINE $303C, $1704, $A82F;
  263.     {$ENDC}
  264. FUNCTION DBGetSessionNum(sessID: LONGINT; VAR sessNum: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  265.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  266.     INLINE $303C, $0605, $A82F;
  267.     {$ENDC}
  268. FUNCTION DBSend(sessID: LONGINT; text: Ptr; len: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  269.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  270.     INLINE $303C, $0706, $A82F;
  271.     {$ENDC}
  272. FUNCTION DBSendItem(sessID: LONGINT; dataType: DBType; len: INTEGER; places: INTEGER; flags: INTEGER; buffer: UNIV Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  273.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  274.     INLINE $303C, $0B07, $A82F;
  275.     {$ENDC}
  276. FUNCTION DBExec(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  277.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  278.     INLINE $303C, $0408, $A82F;
  279.     {$ENDC}
  280. FUNCTION DBState(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  281.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  282.     INLINE $303C, $0409, $A82F;
  283.     {$ENDC}
  284. FUNCTION DBGetErr(sessID: LONGINT; VAR err1: LONGINT; VAR err2: LONGINT; VAR item1: Str255; VAR item2: Str255; VAR errorMsg: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  285.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  286.     INLINE $303C, $0E0A, $A82F;
  287.     {$ENDC}
  288. FUNCTION DBBreak(sessID: LONGINT; abort: BOOLEAN; asyncPB: DBAsyncParmBlkPtr): OSErr;
  289.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  290.     INLINE $303C, $050B, $A82F;
  291.     {$ENDC}
  292. FUNCTION DBGetItem(sessID: LONGINT; timeout: LONGINT; VAR dataType: DBType; VAR len: INTEGER; VAR places: INTEGER; VAR flags: INTEGER; buffer: UNIV Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  293.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  294.     INLINE $303C, $100C, $A82F;
  295.     {$ENDC}
  296. FUNCTION DBUnGetItem(sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  297.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  298.     INLINE $303C, $040D, $A82F;
  299.     {$ENDC}
  300. FUNCTION DBKill(asyncPB: DBAsyncParmBlkPtr): OSErr;
  301.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  302.     INLINE $303C, $020E, $A82F;
  303.     {$ENDC}
  304. FUNCTION DBGetNewQuery(queryID: INTEGER; VAR query: QueryHandle): OSErr;
  305.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  306.     INLINE $303C, $030F, $A82F;
  307.     {$ENDC}
  308. FUNCTION DBDisposeQuery(query: QueryHandle): OSErr;
  309.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  310.     INLINE $303C, $0210, $A82F;
  311.     {$ENDC}
  312. FUNCTION DBStartQuery(VAR sessID: LONGINT; query: QueryHandle; statusProc: DBStatusUPP; asyncPB: DBAsyncParmBlkPtr): OSErr;
  313.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  314.     INLINE $303C, $0811, $A82F;
  315.     {$ENDC}
  316. FUNCTION DBGetQueryResults(sessID: LONGINT; VAR results: ResultsRecord; timeout: LONGINT; statusProc: DBStatusUPP; asyncPB: DBAsyncParmBlkPtr): OSErr;
  317.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  318.     INLINE $303C, $0A12, $A82F;
  319.     {$ENDC}
  320. FUNCTION DBResultsToText(VAR results: ResultsRecord; VAR theText: Handle): OSErr;
  321.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  322.     INLINE $303C, $0413, $A82F;
  323.     {$ENDC}
  324. FUNCTION DBInstallResultHandler(dataType: DBType; theHandler: DBResultHandlerUPP; isSysHandler: BOOLEAN): OSErr;
  325.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  326.     INLINE $303C, $0514, $A82F;
  327.     {$ENDC}
  328. FUNCTION DBRemoveResultHandler(dataType: DBType): OSErr;
  329.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  330.     INLINE $303C, $0215, $A82F;
  331.     {$ENDC}
  332. FUNCTION DBGetResultHandler(dataType: DBType; VAR theHandler: DBResultHandlerUPP; getSysHandler: BOOLEAN): OSErr;
  333.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  334.     INLINE $303C, $0516, $A82F;
  335.     {$ENDC}
  336. FUNCTION DBIdle: OSErr;
  337.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  338.     INLINE $303C, $00FF, $A82F;
  339.     {$ENDC}
  340.  
  341.  
  342. {$ALIGN RESET}
  343. {$POP}
  344.  
  345. {$SETC UsingIncludes := DatabaseAccessIncludes}
  346.  
  347. {$ENDC} {__DATABASEACCESS__}
  348.  
  349. {$IFC NOT UsingIncludes}
  350.  END.
  351. {$ENDC}
  352.